package modifiers;

import java.util.ArrayList;

import utilities.Key;
import controller.AbstractController;
import eventGenerators.IEventGenerator;
import eventManager.AppEvent;
import eventManager.EventPortal;
import eventManager.IEventData;
import eventStrategies.component.ApplyDataModifierStrategy;
import eventStrategies.component.RemoveDataModifierStrategy;

public class Feature extends AbstractController {
	
	private String name;
	private DataModifier dataMod;
	private ViewModifier viewMod;	
	private ArrayList<IEventGenerator> eventGenerators;
	
	private Key target;
	
	public Feature(String name, 
			Key target, 
			DataModifier dataMod, 
			ViewModifier viewMod,
			ArrayList<IEventGenerator> eventGenerators) {
		this.name = name;
		this.dataMod = dataMod;
		this.viewMod = viewMod;
		this.eventGenerators = eventGenerators;
	}
	
	public void applyDataMod() {
		Object[] objs = new Object[]{dataMod};
		EventPortal.queueEvent(new AppEvent("applyDataModifier", target, objs));
	}
	
	public void removeDataMod() {
		Object[] objs = new Object[]{dataMod.getName()};
		EventPortal.queueEvent(new AppEvent("removeDataModifier", target, objs));
	}
	
	public void applyViewMod() {
		Object[] objs = new Object[]{viewMod};
		EventPortal.queueEvent(new AppEvent("applyViewModifier", target, objs));
	}
	
	public void removeViewMod() {
		Object[] objs = new Object[]{viewMod.getName()};
		EventPortal.queueEvent(new AppEvent("removeViewModifier", target, objs));
	}
	
	public ViewModifier getViewModifier() {
		return this.viewMod;
	}
	
	public DataModifier getDataModifier() {
		return this.dataMod;
	}
	
//	@Override
//	public void handleEvent(IEventData event) {
//		if (event.getEventName().equalsIgnoreCase("applyDataModifier")) {
//			
//		}
//		else if (event.getEventName().equalsIgnoreCase("removeDataModifier")) {
//			
//		}
//		else if (event.getEventName().equalsIgnoreCase("applyViewModifier")) {
//			
//		}
//		else if (event.getEventName().equalsIgnoreCase("removeViewModifier")) {
//			
//		}
//		
//		
//	}

	@Override
	public void loadSpecificEventStrategies() {		
		for (IEventGenerator eventGen: eventGenerators) {
			this.loadStrategy(eventGen);
		}		
		
//		this.loadStrategy(new ApplyDataModifierStrategy(target, dataMod));
//		this.loadStrategy(new RemoveDataModifierStrategy(target, dataMod));
//		
//		this.loadStrategy(new ApplyViewModifierStrategy());
//		this.loadStrategy(new RemoveViewModifierStrategy());		
	}
	
	

}
